package com.yunxi.controller.customer;

import com.yunxi.customer.pojo.CustomerFlowVO;
import com.yunxi.customer.service.CustomerFlowDubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.yunxi.core.web.ResponseUtil;

import java.util.*;

import com.yunxi.core.web.CurrentUser;
import com.yunxi.core.web.ApiResult;
import com.yunxi.core.web.LoginInfo;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 客户流量 前端控制器
 * </p>
 *
 * @author
 * @since 2019-08-24
 */
@RestController
@RequestMapping("/admin/customerflow")
@Api(tags = "pms:customerflow", description = "客户流量接口")
public class CustomerFlowController {
   private static final Logger logger = LoggerFactory.getLogger(CustomerFlowController.class);

   @Autowired
   CustomerFlowDubboService customerFlowDubboService;

   @GetMapping("/page")
   @ApiOperation(value = "查询客户流量分页")
   public ApiResult page(CustomerFlowVO customerFlowVO, Integer pageNum, Integer pageSize) throws Exception {
      return ResponseUtil.ok(customerFlowDubboService.findPageByVO(customerFlowVO, pageNum, pageSize));
   }

   @GetMapping("/list")
   @ApiOperation(value = "查询客户流量列表")
   public ApiResult list(CustomerFlowVO customerFlowVO) throws Exception {
      return ResponseUtil.ok(customerFlowDubboService.listByVo(customerFlowVO));
   }

   @GetMapping("/load")
   @ApiOperation(value = "读取单个客户流量")
   public ApiResult load(CustomerFlowVO customerFlowVO, @CurrentUser LoginInfo loginInfo) throws Exception {
      return ResponseUtil.ok(customerFlowDubboService.getById(customerFlowVO.getCustomerFlowId()));
   }

   @PostMapping("/save")
   @ApiOperation(value = "保存客户流量信息")
   public ApiResult save(@RequestBody CustomerFlowVO customerFlowVO, @CurrentUser LoginInfo loginInfo) throws Exception {
      customerFlowDubboService.saveOrUpdate(customerFlowVO);
      return ResponseUtil.ok("success");
   }

   @PostMapping("/del")
   @ApiOperation(value = "删除客户流量")
   public ApiResult del(@RequestBody List<CustomerFlowVO> customerFlowVOList) throws Exception {
      customerFlowDubboService.removeByListVo(customerFlowVOList);
      return ResponseUtil.ok("success");
   }

/*@PostMapping("/export")
@ApiOperation(value = "导出excel")
public Object export(@RequestParam Map<String,Object> params) throws Exception {
return ResponseUtil.ok(customerFlowDubboService.findMapByList(params));
}*/
}
